package com.hst.capacity.infra.persistence.jpa.order.express;

import com.hst.capacity.domain.model.entity.order.express.ExpressOrderEntity;
import com.hst.capacity.domain.model.entity.order.express.ExpressOrderSettlementEntity;
import com.hst.capacity.domain.model.response.express.ExOrderSettlementViewVO;
import com.hst.capacity.domain.model.response.setting.price.ExpressStpSearchVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface ExOrderSettlementRepository extends JpaRepository<ExpressOrderSettlementEntity, String>, JpaSpecificationExecutor<ExpressOrderSettlementEntity> {

    /**
     * 根据订单ID查找订单结算表信息
     * @param idOrder
     * @return
     */
    ExpressOrderSettlementEntity findByIdOrder(String idOrder);

    @Query("select new com.hst.capacity.domain.model.response.express.ExOrderSettlementViewVO(v,s) from ExpressOrderSettlementEntity s left join ExOrderSettlementViewEntity v on s.idOrderSettlement = v.idOrderSettlement where v.idFranchisee=:idFranchisee")
    Page<ExOrderSettlementViewVO> findByIdFranchisee(String idFranchisee, PageRequest pageRequest);


}
